<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

Route::any('/session/set/:name', 'app\controller\api\indexController@setSession');
Route::any('/session/get/:name', 'app\controller\api\indexController@getSession');


Route::group('/api', function () {
    //版本V1
    Route::group('/v1', function () {
        Route::any('/test', 'app\controller\api\indexController@index');//测试接口
        Route::get('/product-list', 'app\controller\api\productController@index');//商品列表
        Route::post('/checkout', 'app\controller\api\checkoutController@createCheckout');//生成checkoutId
        Route::post('/draft-create', 'app\controller\api\orderController@createDraftOrder');//创建草稿订单
        Route::put('/draft-modify/:id', 'app\controller\api\orderController@modifyDraftOrder')->model(\app\model\Orders::class);//修改订单
        Route::get('/payment-enable-get', 'app\controller\api\orderController@getPaymentMethod');//获取支付方式
        Route::post('/place-order/:id', 'app\controller\api\orderController@placeOrder')->model(\app\model\Orders::class);//下单
        Route::get('/session-token/:id', 'app\controller\api\orderController@getSessionToken')->model(\app\model\ShopsPayment::class);//sessionToken
        Route::get('/shipping-lines', 'app\controller\api\orderController@getShippingZones');//根据国家获取运费
        Route::post('/pre-paypal', 'app\controller\api\orderController@prePayByPaypal');//paypal预下单
        Route::get('/paypal-config', 'app\controller\api\orderController@getPaypalConfig');//获取paypal配置
        Route::get('/order-status/:id', 'app\controller\api\orderController@getOrderStatus')->model(\app\model\Orders::class);//获取订单状态
        Route::get('/order-detail/:id', 'app\controller\api\orderController@getOrderDetail')->model(\app\model\Orders::class);//获取订单详情
        Route::get('/order-status-url/:id', 'app\controller\api\orderController@getOrderStatusUrl')->model(\app\model\Orders::class);//获取成功页面
        Route::post('/order-confirm/:id', 'app\controller\api\orderController@confirmCheckout')->model(\app\model\Orders::class);//完成支付
        Route::post('/order-logs', 'app\controller\api\orderController@saveOrderLogs');//保存订单日志
        Route::post('/ip-logs', 'app\controller\api\orderController@saveIPLogs');//保存LP日志
        Route::get('/product/:id', 'app\controller\api\productController@read');//商品详情
        Route::post('/repurchase/:id', 'app\controller\api\upsellController@upsell')->model(\app\model\Orders::class);//再次购买
        Route::get('/repurchase/discount', 'app\controller\api\orderController@getRepurchaseDiscount');//获取加购折扣比率
        Route::post('/quick-draft-create', 'app\controller\api\orderController@createPaypalDraftOrder');//创建快捷支付草稿订单
        Route::post('/calculate-total-set', 'app\controller\api\orderController@calculateTotalSet');//计算paypal金额
        Route::any('/notify/:channel', "app\controller\\notify\\notifyController@notify");//异步通知地址
        Route::any('/checkout/:id', "app\controller\\notify\\notifyController@checkout")->model(\app\model\Orders::class);//正常流程跳转
        Route::any('/webhook', 'app\controller\api\webhookController@index');//webhook地址
        Route::get('/dashboard', 'app\controller\api\DashboardController@index');//数据面板
        Route::any('/pixel/track', 'app\controller\api\FaceBookPixelController@track_event');//像素追踪
        Route::post('/calculate/apple/amount', 'app\controller\api\orderController@calculateApplePayTotalSet');//计算苹果支付金额
        Route::post('/capture/integration/paypal/:id', 'app\controller\api\orderController@capturePaypalByGoogleAndApple')->model(\app\model\Orders::class);//google苹果支付
        Route::post('/capture/quick/spreedly', 'app\controller\api\orderController@captureSpreedlyByGoogleAndApple');//spreedly快捷支付
    });


})
    ->middleware(\app\middleware\CheckShopifyRequest::class);//验证前端请求

//后台管理
Route::group('/admin', function () {
    Route::rule('/shop/add', 'app\controller\admin\ShopController@create', 'GET|POST');//添加店铺
    Route::get('/shop/list', 'app\controller\admin\ShopController@index');//店铺列表
    Route::any('/shop/update/:id', 'app\controller\admin\ShopController@update')->model(\app\model\Shops::class);//更新店铺
    Route::delete('/shop/del/:id', 'app\controller\admin\ShopController@delete')->model(\app\model\Shops::class);//删除店铺
    Route::post('/shop/edit/:id', 'app\controller\admin\ShopController@edit')->model(\app\model\Shops::class);//编辑店铺
    Route::post('/shop/status/:id', 'app\controller\admin\ShopController@editShopStatus')->model(\app\model\Shops::class);//编辑店铺
    Route::post('/shop/repurchase/:id', 'app\controller\admin\ShopController@editRepurchaseStatus')->model(\app\model\Shops::class);//编辑店铺
    Route::get('/shop/json', 'app\controller\admin\ShopController@getList');//店铺数据
    Route::get('/shop/payment/:id', 'app\controller\admin\ShopController@getShopPayment')->model(\app\model\Shops::class);//编辑店铺
    Route::get('/login', 'app\controller\admin\AdminController@login');//登录
    Route::get('/home', 'app\controller\admin\AdminController@index');//主页
    Route::post('/login/check', 'app\controller\admin\AdminController@checkLogin');//检查登录
    Route::get('/logout', 'app\controller\admin\AdminController@logout');//退出
    Route::any('/order/list', 'app\controller\admin\OrderController@index');//订单列表
    Route::get('/order/data', 'app\controller\admin\OrderController@getList');//订单数据
    Route::get('/order/:id', 'app\controller\admin\OrderController@show')->model(\app\model\Orders::class);//订单数据
    Route::post('/upload', 'app\controller\admin\ToolController@uploadFile');//上传图片
})->middleware(\app\middleware\CheckUserLogin::class);